package com.bjsxt.cglib;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * cglib代理实现类
 *
 * @author 李春龙
 */
public class ProxyInterceptor implements MethodInterceptor {

    private final RealStar realStar;

    public ProxyInterceptor(RealStar realStar) {
        this.realStar = realStar;
    }

    @Override
    public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
        System.out.println("CGLib代理模式开始。。。");

        Object rtnValue = method.invoke(realStar, args);

        System.out.println("CGLib代理模式结束。。。");

        return rtnValue;
    }

}
